package cn.keepme.controller;

import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Component;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
@Component
@RequestMapping("baseController")
public class BaseController {

	public final String JSP_PATH="/WEB-INF/jsp/";
	
	public final String ENCODING="UTF-8";
	
	
	@RequestMapping("/forward/{jspName}")
	public String redirectJsp(@PathVariable String jspName){
		return "/WEB-INF/jsp/"+jspName+".jsp";
	}
	
	
	protected int getPageSize(HttpServletRequest request,int defaultPageSize){
		String pageSize=request.getParameter("pageSize");//每页显示条数
		if(pageSize==null || "".equals(pageSize) || ("undefined").equals(pageSize)){
			pageSize=String.valueOf(defaultPageSize);
		}
		return Integer.parseInt(pageSize);
	}
	
	protected int getPageNo(HttpServletRequest request,int defaultPageNo){
		String pageNo=request.getParameter("pageNo");//当前页号
		if(pageNo==null || "".equals(pageNo) || ("undefined").equals(pageNo)){
			pageNo=String.valueOf(defaultPageNo);
		}
		return Integer.parseInt(pageNo);
	}
	
}
